package com.nuoniu.sibanyun.entity.crm.call.vo;

import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoField;

/**
 * @ClassName XiangYunResult
 * @Description TODO
 * @Author 白强
 * @Date 2022/5/17 8:42
 * @Version 1.0
 **/
@Data
@ApiModel("祥云-返回结构")
public class XiangYunResult<T> {

    private Boolean success;

    private String message;

    private Integer code;

    private T result;

    private Long timestamp;

    public static XiangYunResult ok(String  message){
        return result(true,200,message,"ok");
    }

    public static XiangYunResult error(int code, String  message) {
        return result(false,code,message,"error");
    }

    public static XiangYunResult result(Boolean success , int code, String  message,Object result) {
        XiangYunResult r = new XiangYunResult();
        r.setSuccess(success);
        r.setCode(code);
        r.setMessage( message);
        r.setResult(result);
        r.setTimestamp(LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli());
        return r;
    }
}
